package com.jingdianjichi.auth.domain.service.Impl;


import com.jingdianjichi.auth.common.enums.IsDeletedCodeEnum;
import com.jingdianjichi.auth.domain.convent.AuthRoleConverter;
import com.jingdianjichi.auth.domain.entity.AuthRoleBo;
import com.jingdianjichi.auth.domain.service.AuthRoleDomainService;
import com.jingdianjichi.auth.infra.basic.entity.AuthRole;
import com.jingdianjichi.auth.infra.basic.service.AuthRoleService;

import javax.annotation.Resource;


public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {
    @Resource
    AuthRoleService authRoleService;

    @Override
    public void add(AuthRoleBo authRoleBo) {
        AuthRole authRole = AuthRoleConverter.INSERT.conventBoTo(authRoleBo);
        authRole.setIsDeleted(IsDeletedCodeEnum.UN_DELETED.getCode());
        authRoleService.insert(authRole);
    }

    @Override
    public Boolean update(AuthRoleBo authRoleBo) {
        AuthRole authRole = AuthRoleConverter.INSERT.conventBoTo(authRoleBo);


        return authRoleService.update(authRole);
    }

    @Override
    public Boolean delect(AuthRoleBo authRoleBo) {
        AuthRole authRole = AuthRoleConverter.INSERT.conventBoTo(authRoleBo);
        authRole.setIsDeleted(IsDeletedCodeEnum.DELETED.getCode());
      return authRoleService.deleteById(authRole.getId());

    }
}
